<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>学并思留言板</title>

    <!-- Bootstrap core CSS -->
    <link href="<?php echo __PUBLIC__; ?>/css/bootstrap.min.css" rel="stylesheet">
     <link href="<?php echo __PUBLIC__; ?>/css/main.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="jumbotron.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="../../assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="./index.php">留言板1.0</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <form class="navbar-form navbar-right" action="login.php" method="post">
            <div class="form-group">
              <input type="text" placeholder="Email" class="form-control" name="username">
            </div>
            <div class="form-group">
              <input type="password" placeholder="Password" class="form-control" name="password">
            </div>
            <button type="submit" class="btn btn-success">登录</button>
          </form>
        </div><!--/.navbar-collapse -->
      </div>
    </nav>



    <div class="main">
        <div class="main_mid">
          <style type="text/css">

              .form-group{
                  margin: 10px;
              }
             .form-group label{
                width: 80px;
             }

             .btn-danger{
                margin-top: 20px;
             }

             .glyphicon-ok{
                color: #5CB85C;
             }

             .glyphicon-remove{
                color: #D9534F;
             }



          </style>
          <div class="col-md-12">
            <form class="form-inline" action="./index.php?m=index&c=register&a=add" method="post">
              <div class="col-md-12">
                  <div class="form-group">
                  <label for="exampleInputName2">用户名</label>
                  <input type="text" class="form-control data_check" id="username" name="username" regcheck='' placeholder="Jane Doe">
                  <span class='notice'></span></span>
                </div>
              </div>
              <div class="col-md-12">
                  <div class="form-group">
                  <label for="exampleInputName2">密码</label>
                  <input type="text" class="form-control data_check" id="passwd" name="passwd" regcheck='' placeholder="Jane Doe">
                  <span class='notice' ></span>
                </div>
              </div>
              <div class="col-md-12">
                  <div class="form-group">
                  <label for="exampleInputName2">重复密码</label>
                  <input type="text" class="form-control data_check1" id="passwd2" name="passwd2" regcheck='' placeholder="Jane Doe">
                  <span class='notice'></span>
                </div>
              </div>
              <div class="col-md-12">
                  <div class="form-group">
                  <label for="exampleInputName2">手机</label>
                  <input type="text" class="form-control data_check" id="phone" name="phone" regcheck='' placeholder="Jane Doe">
                  <span class='notice'></span>
                </div>
              </div>
              <button type="submit" disabled="" id="regbtn" class="btn btn-danger">注册</button>

            </form>
          </div>

        </div>
    </div>



    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="<?php echo __PUBLIC__; ?>/js/jquery.min.js"></script>
    <script src="<?php echo __PUBLIC__; ?>/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
    <script type="text/javascript">

        $(function(){

          // 判断用户名的异步

          $('.data_check').blur(function(event) {
              var this1 = $(this);
              var value = $(this).val();
              var data_name = $(this).attr('name');
              // var obj = {data_name:value};

              $.ajax({
                url: './index.php?m=index&c=register&a=ajax',
                type: 'POST',
                dataType: 'json',
                data: data_name+"="+value,
                success:function(data){
                  if(data.error==1){
                    this1.siblings('.notice').html("<span class='glyphicon glyphicon-ok' aria-hidden='true'></span>");
                    this1.attr({ regcheck: 'regcheck'});

                    var c = 1;
                    var obj = $('.data_check');

                    $.each(obj, function(index, val) {
                       if($(this).attr('regcheck')==''){
                          c=0;
                       }
                    });

                    if(c){
                      $('#regbtn').removeAttr('disabled');
                    }

                  }else{
                    this1.siblings('.notice').html("<span class='glyphicon glyphicon-remove' aria-hidden='true'>"+data.info+"</span>");
                    this1.attr({ regcheck: ''});
                  }
                },
                error:function(){
                  alert('444444');
                }

              })




          });

          $('.data_check1').blur(function(event) {
            
          });




        })

    </script>
  </body>
</html>
